import React from 'react';
import {Toast} from 'antd-mobile';

class Loading extends React.Component{
  constructor(props) {
    super(props);
    
  }

  showLoading = (text) => {
    Toast.loading(text || '加载中', 999999);
  }

  hideLoading = () => {
    Toast.hide();
  }

  componentDidMount() {
    this.props.visible === true && this.showLoading(this.props.text);
  }

  componentWillReceiveProps(nextProps){
    nextProps.visible !== this.props.visible && nextProps.visible === true ? this.showLoading(nextProps.text) : this.hideLoading();
  }

  render() {
    return (
      null
    );
  }
}

export default Loading;